package com.kitty.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.kitty.dao.ICustomerDao;
import com.kitty.model.TCustomer;

public class CustomerDao extends HibernateDaoSupport implements ICustomerDao{

	public TCustomer get(String id) {
		return (TCustomer)getHibernateTemplate().get(TCustomer.class, id);
	}

	public void delete(String id) {
		TCustomer customer = (TCustomer)getHibernateTemplate().get(TCustomer.class, id);
		if (customer != null)
			getHibernateTemplate().delete(customer);
	}

	public void delete(TCustomer customer) {
		if (customer != null)
			getHibernateTemplate().delete(customer);
	}

	@SuppressWarnings("unchecked")
	public List<TCustomer> findAll() {
		return (List<TCustomer>)getHibernateTemplate().find("from TCustomer");
	}

	public String save(TCustomer customer) {
		getHibernateTemplate().saveOrUpdate(customer);
		return customer.id;
	}
	
}
